package com.api.gbhg.daizhishun.util;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import weaver.general.BaseBean;
import weaver.workflow.workflow.WorkflowVersion;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * @description: 读取配置文件的所有报销单流程
 * @author: daizhishun
 * @date: 2021/4/21
 **/
public class ReadProperties extends BaseBean{

    private final Logger logger = LoggerFactory.getLogger("gbhg");

   //读取通用报销流程的配置文件
//    public List<String> read() {
//
//        Properties property = new Properties();
//        try {
//            property.load(new InputStreamReader(ReadProperties.class.getResourceAsStream("../lbz/conf/ReimbursementWorkflowid"), "UTF-8"));
//        } catch (IOException e) {
//            e.printStackTrace();
//        }
//        /*Set<String> strings = */
//        ArrayList<String> list = new ArrayList<>();
//        //129,133,138,139,141,143,145,147,150,151,152,157,156,144,140,136,134,168,169,170,171,172
//        list.add(property.getProperty("YS02Workflowid"));//129
//        list.add(property.getProperty("YS04Workflowid"));//133
//        list.add(property.getProperty("YS05Workflowid"));//138
//        list.add(property.getProperty("YS07Workflowid"));//141
//        list.add(property.getProperty("YS09Workflowid"));//143
//        list.add(property.getProperty("YS11Workflowid"));//147
//        list.add(property.getProperty("YS12Workflowid"));//150
//        list.add(property.getProperty("YS13Workflowid"));//151
//        list.add(property.getProperty("YS14Workflowid"));//152
//        list.add(property.getProperty("YS15Workflowid"));//157
//        list.add(property.getProperty("YS16Workflowid"));//156
//        list.add(property.getProperty("YS23Workflowid"));//144
//        list.add(property.getProperty("YS24Workflowid"));//140
//        list.add(property.getProperty("YS27Workflowid"));//136
//        list.add(property.getProperty("YS28Workflowid"));//134
//        list.add(property.getProperty("YS29Workflowid"));//168
//        list.add(property.getProperty("YS30Workflowid"));//169
//        list.add(property.getProperty("YS31Workflowid"));//170
//        list.add(property.getProperty("YS32Workflowid"));//171
//        list.add(property.getProperty("YS33Workflowid"));//172
//        return list;
//    }


    //单独读取培训费报销流程的配置文件
    public Set<String> TrainingExpense() throws IOException {
        String userFudsWorkflowid06 =WorkflowVersion.getActiveVersionWFID(getPropValue("ReimbursementWorkflowid", "YS06Workflowid"));//读取配置文件
        Set<String> strings = new HashSet<>();
        strings.add(userFudsWorkflowid06);
        return strings;
    }


    //单独读取缉私举报奖金报销报销流程的配置文件
    public Set<String> ReportBonus() throws IOException{
        String userFudsWorkflowid10 =WorkflowVersion.getActiveVersionWFID(getPropValue("ReimbursementWorkflowid", "YS10Workflowid"));//读取配置文件
        Set<String> strings = new HashSet<>();
        strings.add(userFudsWorkflowid10);//145
        return strings;
    }


    public String read2() {


        /*Set<String> strings = */
        //129,133,138,139,141,143,145,147,150,151,152,157,156,144,140,136,134,168,169,170,171,172
        StringBuffer stringBuffer = new StringBuffer();
        stringBuffer.append(WorkflowVersion.getActiveVersionWFID(getPropValue("ReimbursementWorkflowid", "YS02Workflowid"))+",");//129
        stringBuffer.append(WorkflowVersion.getActiveVersionWFID(getPropValue("ReimbursementWorkflowid", "YS06Workflowid"))+",");//139
        stringBuffer.append(WorkflowVersion.getActiveVersionWFID(getPropValue("ReimbursementWorkflowid", "YS04Workflowid"))+",");//133
        stringBuffer.append(WorkflowVersion.getActiveVersionWFID(getPropValue("ReimbursementWorkflowid", "YS05Workflowid"))+",");//138
        stringBuffer.append(WorkflowVersion.getActiveVersionWFID(getPropValue("ReimbursementWorkflowid", "YS10Workflowid"))+",");//145
        stringBuffer.append(WorkflowVersion.getActiveVersionWFID(getPropValue("ReimbursementWorkflowid", "YS07Workflowid"))+",");//141
        stringBuffer.append(WorkflowVersion.getActiveVersionWFID(getPropValue("ReimbursementWorkflowid", "YS09Workflowid"))+",");//143
        stringBuffer.append(WorkflowVersion.getActiveVersionWFID(getPropValue("ReimbursementWorkflowid", "YS11Workflowid"))+",");//147
        stringBuffer.append(WorkflowVersion.getActiveVersionWFID(getPropValue("ReimbursementWorkflowid", "YS12Workflowid"))+",");//150
        stringBuffer.append(WorkflowVersion.getActiveVersionWFID(getPropValue("ReimbursementWorkflowid", "YS13Workflowid"))+",");//151
        stringBuffer.append(WorkflowVersion.getActiveVersionWFID(getPropValue("ReimbursementWorkflowid", "YS14Workflowid"))+",");//152
        stringBuffer.append(WorkflowVersion.getActiveVersionWFID(getPropValue("ReimbursementWorkflowid", "YS15Workflowid"))+",");//157
        stringBuffer.append(WorkflowVersion.getActiveVersionWFID(getPropValue("ReimbursementWorkflowid", "YS16Workflowid"))+",");//156
        stringBuffer.append(WorkflowVersion.getActiveVersionWFID(getPropValue("ReimbursementWorkflowid", "YS23Workflowid"))+",");//144
        stringBuffer.append(WorkflowVersion.getActiveVersionWFID(getPropValue("ReimbursementWorkflowid", "YS24Workflowid"))+",");//140
        stringBuffer.append(WorkflowVersion.getActiveVersionWFID(getPropValue("ReimbursementWorkflowid", "YS27Workflowid"))+",");//136
        stringBuffer.append(WorkflowVersion.getActiveVersionWFID(getPropValue("ReimbursementWorkflowid", "YS28Workflowid"))+",");//134
        stringBuffer.append(WorkflowVersion.getActiveVersionWFID(getPropValue("ReimbursementWorkflowid", "YS29Workflowid"))+",");//168
        stringBuffer.append(WorkflowVersion.getActiveVersionWFID(getPropValue("ReimbursementWorkflowid", "YS30Workflowid"))+",");//169
        stringBuffer.append(WorkflowVersion.getActiveVersionWFID(getPropValue("ReimbursementWorkflowid", "YS31Workflowid"))+",");//170
        stringBuffer.append(WorkflowVersion.getActiveVersionWFID(getPropValue("ReimbursementWorkflowid", "YS32Workflowid"))+",");//171
        stringBuffer.append(WorkflowVersion.getActiveVersionWFID(getPropValue("ReimbursementWorkflowid", "YS33Workflowid")));//172
        return stringBuffer.toString();
    }


    public List<String> getworkflowid(){
        List<String> list = new ArrayList<>();
        list.add(WorkflowVersion.getActiveVersionWFID(getPropValue("ReimbursementWorkflowid", "YS06Workflowid")));//139
        list.add(WorkflowVersion.getActiveVersionWFID(getPropValue("ReimbursementWorkflowid", "YS10Workflowid")));//145
        list.add(WorkflowVersion.getActiveVersionWFID(getPropValue("ReimbursementWorkflowid", "YS14Workflowid")));//152
        list.add(WorkflowVersion.getActiveVersionWFID(getPropValue("ReimbursementWorkflowid", "YS15Workflowid")));//157
        list.add(WorkflowVersion.getActiveVersionWFID(getPropValue("ReimbursementWorkflowid", "YS29Workflowid")));//168
        return list;

    }
    public StringBuffer Accountingnodename(){
            String activeVersionWFID =getPropValue("ReimbursementWorkflowid","Accountingnodename");
            logger.info("读取会计节点配置文件···"+activeVersionWFID);
            StringBuffer sb = new StringBuffer();
            String[] split = activeVersionWFID.split(",");
            for (int i = 0; i < split.length; i++) {
                if (i == split.length - 1) {
                    sb.append("'" + split[i] + "'");
                } else {
                    sb.append("'" + split[i] + "',");
                }

            }
        logger.info("读取会计节点配置文件结束··· 结果："+activeVersionWFID);
        return new StringBuffer().append("'会计核单','会计审核','会计主管审核'");
    }

}
